package fei.yuzhi.com.loveflowers.fragment.firstpagefragment.detail.evaluate;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.RadioButton;
import android.widget.TextView;

import java.util.List;

import fei.yuzhi.com.loveflowers.R;
import fei.yuzhi.com.loveflowers.bean.evaluatebean.CommentsListBean;
import fei.yuzhi.com.loveflowers.bean.firstpagedetailbean.GoodsCommendListBean;
import fei.yuzhi.com.loveflowers.bean.searchbean.GoodsListBean;

/**
 * Created by My on 2016/10/18.
 */
public class EvaluateListAdapter extends BaseAdapter {
    private Context context;
    private List<CommentsListBean> commentsListBeen;
    private RadioButton radioButton;
    public EvaluateListAdapter(Context context,List<CommentsListBean> commentsListBeen,RadioButton radioButton){
        this.context=context;
        this.commentsListBeen=commentsListBeen;
        this.radioButton=radioButton;
    }
    @Override
    public int getCount() {
        return commentsListBeen.size();
    }

    @Override
    public Object getItem(int position) {
        return commentsListBeen.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHolder holder=null;
        if (convertView==null){
            convertView= LayoutInflater.from(context).inflate(R.layout.item_evaluate_list,null);
            holder=new ViewHolder();
            holder.geval_addtime= (TextView) convertView.findViewById(R.id.geval_addtime);
            holder.geval_content= (TextView) convertView.findViewById(R.id.geval_content);
            holder.geval_frommembername= (TextView) convertView.findViewById(R.id.geval_frommembername);
            convertView.setTag(holder);
        }else{
            holder= (ViewHolder) convertView.getTag();
        }
        int id=radioButton.getId();
        if (id==R.id.evaluate_all){
            holder.geval_content.setText(commentsListBeen.get(position).getGeval_content());
            holder.geval_frommembername.setText(commentsListBeen.get(position).getGeval_frommembername());
            holder.geval_addtime.setText(commentsListBeen.get(position).getGeval_addtime());
        }
        if (id==R.id.evaluate_good){
            holder.geval_content.setText(commentsListBeen.get(position).getGeval_content());
            holder.geval_frommembername.setText(commentsListBeen.get(position).getGeval_frommembername());
            holder.geval_addtime.setText(commentsListBeen.get(position).getGeval_addtime());
        }else if (id==R.id.evaluate_bad||id==R.id.evaluate_normal||id==R.id.evaluate_have_image){
            holder.geval_content.setText("");
            holder.geval_frommembername.setText("");
            holder.geval_addtime.setText("");
        }
        return convertView;
    }
    static class ViewHolder{
        TextView geval_addtime,geval_content,geval_frommembername;
    }
}
